package com.example.hellodemo;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.example.hellodemo.constraint.ConstraintActivity;
import com.example.hellodemo.listView.GrideViewActivity;
import com.example.hellodemo.listView.ListViewActivity;
import com.example.hellodemo.navigationBar.BottomNavigationBarActivity;
import com.example.hellodemo.recyclerView.RecyclerViewActivity;
import com.example.hellodemo.widget.CustomUIActivity;

public class UIActivity extends AppCompatActivity {

    private Button textViewBtn;
    private Button mbtn;
    private Button btn3;
    private Button radioBtn;
    private Button checkBoxBtn;
    private Button imgViewBtn;
    private Button listViewBtn;
    private Button grideBtn;
    private Button cyclerViewBtn, webviewBtn,toastBtn,alertDialogBtn,progressViewBtn,customDialogBtn,popupWindowBtn,bottomNavigaionBarBtn,customUIBtn,constraintBtn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ui);

        textViewBtn = findViewById(R.id.btn_textview);
        mbtn = findViewById(R.id.btn_2);
        btn3 = findViewById(R.id.btn3);
        radioBtn = findViewById(R.id.raido_button);
        checkBoxBtn = findViewById(R.id.checkbox);
        imgViewBtn = findViewById(R.id.imageview);
        listViewBtn = findViewById(R.id.listview);
        grideBtn = findViewById(R.id.gridviewBtn);
        cyclerViewBtn = findViewById(R.id.cyclerViewBtn);
        webviewBtn = findViewById(R.id.webviewBtn);
        toastBtn = findViewById(R.id.toastBtn);
        alertDialogBtn = findViewById(R.id.alertDialog);
        progressViewBtn  = findViewById(R.id.progressView);
        customDialogBtn = findViewById(R.id.customDialogView);
        popupWindowBtn = findViewById(R.id.popupWindow);
        bottomNavigaionBarBtn = findViewById(R.id.bottomNavigaionBar);
        customUIBtn = findViewById(R.id.customUI);
        constraintBtn = findViewById(R.id.constraint);
        setListeners();

    }
    private  void setListeners(){
        OnClick onClick = new  OnClick();
        textViewBtn.setOnClickListener(onClick);
        mbtn.setOnClickListener(onClick);
        btn3.setOnClickListener(onClick);
        radioBtn.setOnClickListener(onClick);
        checkBoxBtn.setOnClickListener(onClick);
        imgViewBtn.setOnClickListener(onClick);
        listViewBtn.setOnClickListener(onClick);
        grideBtn.setOnClickListener(onClick);
        cyclerViewBtn.setOnClickListener(onClick);
        webviewBtn.setOnClickListener(onClick);
        toastBtn.setOnClickListener(onClick);
        alertDialogBtn.setOnClickListener(onClick);
        progressViewBtn.setOnClickListener(onClick);
        customDialogBtn.setOnClickListener(onClick);
        popupWindowBtn.setOnClickListener(onClick);
        bottomNavigaionBarBtn.setOnClickListener(onClick);
        customUIBtn.setOnClickListener(onClick);
        constraintBtn.setOnClickListener(onClick);
    }
    // 实现点击回调的接口 用来做委托代理对象
    private class OnClick implements View.OnClickListener{
        @Override
        public void onClick(View v) {
            Intent intent = null;
            switch (v.getId()){
                //挑战到TextView演示界面
                case R.id.btn_textview:
                    intent = new Intent(UIActivity.this, TextViewActivity.class);
                break;
                case  R.id.btn_2:
                    intent = new Intent(UIActivity.this, ButtonActivity.class);
                break;
                case  R.id.btn3:
                    intent = new Intent(UIActivity.this,EditTextActivity.class);
                break;
                //跳转到RadioButton演示界面
                case  R.id.raido_button:
                    intent = new  Intent(UIActivity.this,RadioButtonActivity.class);
                    Log.d("ff","fff");
                    break;
                 //跳转到多选框
                case  R.id.checkbox:
                    intent = new Intent(UIActivity.this,CheckBoxActivity.class);
                    break;
                //跳转到图片
                case  R.id.imageview:
                    intent = new Intent(UIActivity.this,ImageViewActivity.class);
                    break;
                //跳转到listView
                case  R.id.listview:
                    intent = new Intent(UIActivity.this, ListViewActivity.class);
                    break;
                case R.id.gridviewBtn:
                    intent = new Intent(UIActivity.this, GrideViewActivity.class);
                    break;
                case R.id.cyclerViewBtn:
                    intent = new Intent(UIActivity.this, RecyclerViewActivity.class);
                    break;
                case  R.id.webviewBtn:
                    intent = new Intent(UIActivity.this, WebViewActivity.class);
                    break;
                case  R.id.toastBtn:
                    intent = new Intent(UIActivity.this, ToastActivity.class);
                break;
                case  R.id.alertDialog:
                    intent = new Intent(UIActivity.this, AlertDialogActivity.class);
                    break;
                case  R.id.progressView:
                    intent = new Intent(UIActivity.this, ProgressActivity.class);
                    break;
                case  R.id.customDialogView:
                    intent = new Intent(UIActivity.this, CustomDialogActivity.class);
                    break;
                case  R.id.popupWindow:
                    intent = new Intent(UIActivity.this, PopupWindowActivity.class);
                    break;
                case R.id.bottomNavigaionBar:
                    intent = new Intent(UIActivity.this, BottomNavigationBarActivity.class);
                    break;
                case R.id.customUI:
                    intent = new Intent(UIActivity.this, CustomUIActivity.class);
                    break;
                case R.id.constraint:
                    intent = new Intent(UIActivity.this, ConstraintActivity.class);
                    break;
            }
            startActivity(intent);
        }

    }
}


